package com.atom.module.mvvm.extren

sealed class BooleanExt<out T>

object Otherwise : BooleanExt<Nothing>()

class TransferData<T>(val data: T) : BooleanExt<T>()

inline fun <T> Boolean.isYes(block: () -> T): BooleanExt<T> = when {
    this -> {
        TransferData(block.invoke())
    }
    else -> {
        Otherwise
    }
}

inline fun <T> BooleanExt<T>.isNo(block: () -> T): T = when (this) {
    is Otherwise -> block()
    is TransferData -> this.data
}